package functional_thinking._2;

import java.util.stream.IntStream;

public class NumberClassifier2 {

	public static IntStream factorsOf(int number) {
		return IntStream.range(1, number + 1)
				.filter(potential -> number % potential == 0);
	}

	public static int aliquoSum(int number) {
		return factorsOf(number).sum() - number;
	}

	public static boolean isPerfect(int number) {
		return aliquoSum(number) == number;
	}

	public static boolean isAbundant(int number) {
		return aliquoSum(number) > number;
	}

	public static boolean isDeficient(int number) {
		return aliquoSum(number) < number;
	}

	public static void main(String[] args) {
		// 6 28
		boolean r = NumberClassifier2.isPerfect(6);
		System.out.println(r);
	}

}
